package com.gua.jbs.controller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;

import com.gua.jbs.service.IStockService;
import com.gua.jbs.serviceImpl.StockService;

/**
 * Controller to maintain the stock in the product stock table
 * 
 * @author Piyush
 * 
 */
public class StockController extends BaseController {

	private static final Logger logger = Logger
			.getLogger(StockController.class);
	private IStockService stockService = null;

	public StockController() {
		stockService = new StockService();
	}

	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {

		// Get the action parameter to understand the type of request
		// String action = request.getParameter(ApplicationConstant.ACTION);
		try {
			List<Object[]> productStockList = stockService
					.getAllProductStocks();
			request.setAttribute("stock", productStockList);
			rd = request.getRequestDispatcher("/pages/jsp/stockReport.jsp");
			rd.forward(request, response);
		} catch (Exception e) {
			logger.error(e.getMessage());
		}
	}
}
